import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import { useChatStore } from './store/chat'

// 导入Vant组件
import Vant from 'vant'
import 'vant/lib/index.css'
import './styles/main.css'

// 创建应用实例
const app = createApp(App)

// 使用插件
app.use(createPinia())
app.use(router)
app.use(Vant)

// 初始化应用
app.mount('#app')

// 获取store实例并初始化
const chatStore = useChatStore()
chatStore.init()

// 添加全局状态同步
window.addEventListener('storage', (event) => {
  if (event.key === 'elderlyModeEnabled') {
    console.log('main.ts检测到适老化模式变化:', event.newValue)
    // 重新初始化store，这会加载适老化模式设置
    chatStore.init()
  }
})

// 添加调试信息
console.log('应用已初始化，适老化模式状态:', chatStore.elderlyModeEnabled)
